﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ManageData
{
    internal class 删除实体
    {
        void MyMethod()
        {
            // 查询删除
            using (var db = new BasicDbContext())
            {
                var entity = db.BasicEntities.First();

                db.Remove(entity);

                db.BasicEntities.Remove(entity);

                db.SaveChanges();
            }

            // 直接删除
            using (var db = new BasicDbContext())
            {
                var entity = new BasicEntity { Id = 1 };
                db.BasicEntities.Remove(entity);
                db.SaveChanges();
            }
        }
    }
}
